from django.shortcuts import render
from django.http import HttpResponse
from study.models import Test
import json
# Create your views here.


def hello(request):
    print(request.method)
    print(request.GET)
    return HttpResponse(json.dumps("Hello world Django", ensure_ascii=False))


def createdb(request):
    test1 = Test.objects.create(name='jake')
    test1.save()
    return HttpResponse(json.dumps("<h1>新增数据成功</h1>", ensure_ascii=False))


def getdb(request):
    arr = list(Test.objects.values())
    return HttpResponse(json.dumps(arr, ensure_ascii=False))
